package com.xyzh05.dao.hibernate;

import java.sql.SQLException;

import com.xyzh05.model.Plan;
import com.xyzh05.dao.PlanDao;
import com.xyzh05.dao.hibernate.GenericDaoHibernate;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;

@Repository("planDao")
public class PlanDaoHibernate extends GenericDaoHibernate<Plan, Long> implements PlanDao {

    public PlanDaoHibernate() {
        super(Plan.class);
    }
    
    public void batchDel(final String delhql, final Object...objects){
    	this.getHibernateTemplate().execute(new HibernateCallback<Object>() {
			public Object doInHibernate(Session session) throws HibernateException,
					SQLException {			
				Query query = session.createQuery(delhql);
				int i = 0;
				for(Object obj : objects){
					query.setParameter(i, obj);
					i++;
				}		
				query.executeUpdate();
				return null;
			}    		
		});
    }
}
